package com.huang.app.antstore.common.views;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.StyleRes;
import android.support.design.widget.BottomSheetDialog;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;

import com.huang.app.antstore.common.R;


/**
 * Created by Huang on 2016/9/28.
 */

public class MyBottomSheetDialog extends BottomSheetDialog {
    RecyclerView.Adapter mAdapter;

    public MyBottomSheetDialog(@NonNull Context context, RecyclerView.Adapter adapter) {
        super(context, R.style.myDialog);
        mAdapter = adapter;
        init();
    }

    public MyBottomSheetDialog(@NonNull Context context, @StyleRes int theme, RecyclerView.Adapter adapter) {
        super(context, theme);
        mAdapter = adapter;
        init();
    }

    public MyBottomSheetDialog(@NonNull Context context, boolean cancelable, OnCancelListener cancelListener, RecyclerView.Adapter adapter) {
        super(context, cancelable, cancelListener);
        mAdapter = adapter;
        init();
    }

    private void init() {
        View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_sheet_pic_from, null);
        RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.rv_list);
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
        recyclerView.setAdapter(mAdapter);
        view.findViewById(R.id.tv_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
        setContentView(view);
    }


}
